set more off

eststo clear

foreach city in memphis nashville {

	use "dataset_`city' wave 1", clear
 
	local X white female homeowner college age democrat

	if "`city'" == "memphis" local y votestrickland
	if "`city'" == "nashville" local y votebarry
	
	foreach x in ideoself1 `X' {
		su `x' if !mi(`y') & !mi(ideoself1)
		replace `x' = (`x' - r(min)) / (r(max) - r(min))
	}
	eststo: reg `y' ideoself1, robust

	foreach x in ideoself1 `X' {
		reg ideoself1 `X'
		keep if e(sample)
		su `x'
		replace `x' = (`x' - r(min)) / (r(max) - r(min))
	}
	
	eststo: reg `y' ideoself1, robust
	
	eststo: reg `y' `X', robust

	eststo: reg `y' ideoself1 `X', robust


}

#delimit;

esttab
	using "table 2.tex"
	,
		replace
		label
		width(\textwidth)		
		gap
		booktabs
		collabels(none)
		nomtitles
		eqlabels(none)
		cells(b(fmt(2) star) se(par))		 
		stats(
			N
			,
				fmt(%20.00fc)
				label("Sample size")
		)
		mgroups(
			"Memphis" "Nashville"
			,
				pattern(1 0 0 0 1 0 0 0)
				prefix(\multicolumn{@span}{c}{) suffix(})
				span erepeat(\cmidrule(lr){@span})
		)			
		;
		
#delimit cr
